import type { BaiduElements } from '../../../../../../../../types/constants'
import type { ThemeType } from '../../../../../../../../types/interfaces'
import { ThemeVarService } from '../../../../../../../../lib/abstract/style/theme_var/service'
import {
  generateHideSelector,
  PAGE_ELEMENTS,
  SUPPORTED_PLATFORMS,
} from '../../../../../../../../types/constants'
import { BaiduWebPage } from './web'

export class BaiduNewsPage {
  elements: BaiduElements = PAGE_ELEMENTS[SUPPORTED_PLATFORMS.BAI_DU]
  private static instance: BaiduNewsPage
  private readonly baiduWebPage: BaiduWebPage = BaiduWebPage.getInstance()
  private readonly themeVarService: ThemeVarService = ThemeVarService.getInstance()

  /**
   * 获取单例实例
   */
  public static getInstance(): BaiduNewsPage {
    if (!BaiduNewsPage.instance) {
      BaiduNewsPage.instance = new BaiduNewsPage()
    }
    return BaiduNewsPage.instance
  }

  init(): void {
  }

  getMainStyles(theme: ThemeType): string {
    return `
/* 隐藏样式 */
#wrapper #wrapper_wrapper #container:has(${generateHideSelector('#header_top_bar')}) {
  ${this.baiduWebPage.containerSelector} {
    margin-top: ${this.themeVarService.search.resultItem.gap} !important;
  }
}
${this.baiduWebPage.getMainStyles(theme)}
`
  }
}
